using UnityEngine;
using System.Collections;

public class RecordManager : MonoBehaviour {
	
	private static string forsave_meterrecord = "milgatosrecordedemetros";
	private static string forsave_scorerecord = "milgatosrecordedepontos";
	
	private static int lastScoreRecord;
	private static int scoreRecord;
	
	private static int lastMeterRecord;
	private static int meterRecord;
	
	public static int getMeterRecord()
	{
		return meterRecord;
	}
	public static int getScoreRecord()
	{
		return scoreRecord;
	}
	public static int getLastMeterRecord()
	{
		return lastMeterRecord;
	}
	public static int getLastScoreRecord()
	{
		return lastScoreRecord;
	}
    public static void setLastScoreRecord(int score) 
    {
        lastScoreRecord = score;
    }
    public static void setLastMeterRecord(int meter)
    {
        lastMeterRecord = meter;
    }
	
	void Awake()
	{
		Load();
	}
	
	public static void Load()
	{
		meterRecord = PlayerPrefs.GetInt(forsave_meterrecord);
		scoreRecord = PlayerPrefs.GetInt(forsave_scorerecord);
	}
	public static void Save()
	{
		PlayerPrefs.SetInt(forsave_meterrecord, meterRecord);
		PlayerPrefs.SetInt(forsave_scorerecord, scoreRecord);
	}
	
	public static void HandleMatchScore(int matchMeters, int matchScore)
	{
		if(matchMeters > meterRecord){
			meterRecord = matchMeters;
		}
		
		if(matchScore > scoreRecord){
			scoreRecord = matchScore;
		}
		
		Save();
	}
	
}
